home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-23 | 1.3 KB | 44 lines | [TEXT/KEEN] |
- #$ClipMagicTemplate: you can use this as the basis for your
- # own clipboard changers. This example just truncates the
- # clip to its last line.
- BEGIN {
- clipCharsToWatch = 32;
- while (1) # run until <Command><period>...
- {
- # see if clipboard has changed
- if ((newClip = getclip(clipCharsToWatch)) != oldClip)
- {
- oldClip = newClip;
- # a leading space is used as the trigger
- if (substr(newClip, 1,1) == " ")
- DoSomething()
- }
- }
- }
-
- function DoSomething( fullClip, numLines, lines, outClip, out)
- {
- fullClip = getclip(); # gets calling editor's private clip
- numLines = split(fullClip, lines, "\r");
- # with "split", the last line will be empty if the last
- # character copied was a return.
- if (lines[numLines] == "")
- --numLines;
-
- #...do things with the clipboard, and create the new clip "out"
- ### just for example, keep only the last line of the old clip
- out = out lines[numLines] "\r";
-
- # In this specific case, since we are looking for a space at
- # the beginning of the clip, make sure our new clip does NOT
- # start with a space
- sub(/^[ ]+/, "", out); # that's a [space] there
-
- # send the result back to the calling editor's clip
- putclip(out);
- # update "oldClip"
- oldClip = substr(out, 1, 32);
- # flash menu bar to signal something happened
- beep(0);
- }
-